package osutil;

import java.awt.AWTException;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.Closeable;
import java.io.File;
import java.io.ObjectOutputStream;
import java.io.OutputStream;

import javax.imageio.ImageIO;
import javax.imageio.stream.ImageOutputStream;

public class ScreenShot {
	public void screenShot(ObjectOutputStream out){
		Robot robot; 
		try {
			robot = new Robot();
			BufferedImage screenShot = robot.createScreenCapture(new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()));
			//ImageIO.write(screenShot, "JPG", new File("c:\\screenShot.jpg"));
			//ImageOutputStream ios = ImageIO.createImageOutputStream(out);		
			//ByteArrayOutputStream baos = new ByteArrayOutputStream();
			//ImageIO.write(screenShot, "JPG", baos);
			//baos.flush();	
			//out.write(baos.toByteArray());
			SerBuffImage sbi = new SerBuffImage(screenShot);
			out.writeObject(sbi);
			out.flush();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			//e.printStackTrace();
		}
		
	}
}
